package com.huli.controller;

import com.huli.domain.OrderInfo;
import com.huli.service.OrderInfoPatientService;
import com.huli.util.Result;
import com.huli.vo.OrderInfoPatientVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/orderInfoPatient")
public class OrderInfoPatientController {
    @Autowired
    private OrderInfoPatientService orderInfoPatientService;
    //查询订单未完成状态的列表
    @RequestMapping("/getOrderInfoPatientListNotOk")
    public Result getOrderInfoPatientListNotOk() {
        try {
           List<OrderInfo> getAllDonOk = orderInfoPatientService.getOrderInfoPatientListNotOk();
           return Result.success(getAllDonOk);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //查询订单未完成状态的列表1
    @RequestMapping("getOrderInfoPatientListNotOk1")
    public Result getOrderInfoPatientListNotOk1(){
        try{
            List<OrderInfo> list=orderInfoPatientService.getOrderInfoPatientListNotOk1();
            return Result.success(list);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }


    // 查询工单列表
    @RequestMapping("/getOrderInfoPatientList")
    public Result getOrderInfoPatientList() {
        try {
            List<OrderInfoPatientVo> orderInfoPatientList = orderInfoPatientService.getOrderInfoPatientList();
            return Result.success(orderInfoPatientList);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }
    // 查询工单列表
    @RequestMapping("/get1")
    public Result getOrder(){
        try {
            List<OrderInfo>list= orderInfoPatientService.getOrder();
            return Result.success(list);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    // 查询工单列表状态待派单
    @RequestMapping("/getOrderInfoPatientList0")
    public Result getOrderInfoPatientList0() {
        try {
            List<OrderInfoPatientVo> orderInfoPatientList = orderInfoPatientService.getOrderInfoPatientList0();
            return Result.success(orderInfoPatientList);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    // 查询工单列表状态待服务
    @RequestMapping("/getOrderInfoPatientList1")
    public Result getOrderInfoPatientList1() {
        try {
            List<OrderInfoPatientVo> orderInfoPatientList = orderInfoPatientService.getOrderInfoPatientList1();
            return Result.success(orderInfoPatientList);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }
    // 查询工单列表状态服务中
    @RequestMapping("/getOrderInfoPatientList2")
    public Result getOrderInfoPatientList2() {
        try {
            List<OrderInfoPatientVo> orderInfoPatientList = orderInfoPatientService.getOrderInfoPatientList2();
            return Result.success(orderInfoPatientList);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }
    // 查询工单列表状态以完成
    @RequestMapping("/getOrderInfoPatientList3")
    public Result getOrderInfoPatientList3() {
        try {
            List<OrderInfoPatientVo> orderInfoPatientList = orderInfoPatientService.getOrderInfoPatientList3();
            return Result.success(orderInfoPatientList);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }
    // 查询工单列表状态已取消
    @RequestMapping("/getOrderInfoPatientList4")
    public Result getOrderInfoPatientList4() {
        try {
            List<OrderInfoPatientVo> orderInfoPatientList = orderInfoPatientService.getOrderInfoPatientList4();
            return Result.success(orderInfoPatientList);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }
    // 修改预约时间
    @RequestMapping("/updateAppointmentTime")
    public Result updateAppointmentTime(Long id , Date finishTime) {
        try {
            orderInfoPatientService.updateAppointmentTime(id,finishTime);
            return Result.success("修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("修改失败");
        }
    }

    // 删除订单
    @RequestMapping("/deleteOrder")
    public Result deleteOrder(Long id) {
        try {
            orderInfoPatientService.deleteOrder(id);
            return Result.success("取消成功");
        }catch (Exception e) {
            e.printStackTrace();
            return Result.error("取消失败");
        }
    }
}
